fix(perf): per-module benchmark works for ResNet (and similar HF models)#586
Merged
Conversation
Collaborator
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
timenick
reviewed
May 12, 2026
timenick
approved these changes
May 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes
winml perf --module <ClassName>on HuggingFace models likemicrosoft/resnet-50, which previously failed withAttributeError: <Parent> has no attribute '<...>'and, once that was past,forward() missing 1 required positional argument.Two root causes:
Wrong parent class instantiated.
_perf_modulespassed the CLItask(typicallyNone) to_instantiate_parent_model. When the model_type's first supported task differs from the architectures-derived task used bygenerate_hf_build_config, the parent class mismatches the recordedmodule_path. Formicrosoft/resnet-50, build configs useResNetForImageClassification(paths prefixed withresnet.), but perf was instantiating bareResNetModel→AttributeError: ResNetModel has no attribute 'resnet'. Fix: re-resolve the parent task from the model_id viaresolve_loader_config, matching the path used to computemodule_path.Wrong input tensor names.
_build_submodule_confighardcoded input names asinput_0,input_1, …, but PyTorch submodules expect specific positional/keyword names (e.g.,ResNetStage.forward(input),ResNetBottleNeckLayer.forward(hidden_state),ResNetEmbeddings.forward(pixel_values)). Callingsubmodule(input_0=tensor)raisesforward() missing 1 required positional argument. Fix: propagate forward-arg names throughSubmoduleInfo.input_names(sourced from the existing hook-capture data, with ainspect.signaturefallback) and use them when buildingInputTensorSpec. Falls back toinput_{i}only when names can't be discovered.End-to-end on a CPU box:
Closes #192